package com.xiyun.msm.controller;


import com.xiyun.common.response.result.R;
import com.xiyun.msm.service.MsmService;
import com.xiyun.msm.utils.RandomUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/xiyun/msm/message")
public class MsmController {

    @Autowired
    private MsmService msmService;

    /**
     * 发送手机验证码
     * @return
     */
    @GetMapping("send/{phone}")
    public R sendAliMsg(@PathVariable String phone){
        String code = RandomUtil.getFourBitRandom();
        boolean send = msmService.sendAliyunMsg(phone,code);
        return send ? R.ok().data("code",code): R.error().message("短信获取失败");
    }

}
